package com.dfbz.demo01;

import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class demo07_Dictionary {
    public static void main(String[] args) {

        Dictionary<String,String> dictionary=new Hashtable();

        dictionary.put("新疆","乌鲁木齐");
        dictionary.put("青海","西宁");
        dictionary.put("辽宁","沈阳");

        System.out.println(dictionary);     // {青海=西宁, 辽宁=沈阳, 新疆=乌鲁木齐}

        String city = dictionary.get("辽宁");     // 沈阳
        System.out.println(city);

        System.out.println("---------");
        Enumeration<String> keys = dictionary.keys();

        while (keys.hasMoreElements()){
            String key = keys.nextElement();
            System.out.println(key);
        }

    }
}
